package org.h.aibuildplatform.common.utils;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;

@Component
public class Redisutils {

    @Resource
    private RedisTemplate redisTemplate;



    public void setToken(String key,Object value){
        redisTemplate.opsForValue().set(key,value,30,TimeUnit.MINUTES);
    }
    public void setVerificationCode(String key,Object value){
        redisTemplate.opsForValue().set(key,value,5,TimeUnit.MINUTES);
    }

    public Object get(String key){
      return  redisTemplate.opsForValue().get(key);
    }

    public void setExpire(String key,Long time){
        redisTemplate.expire(key,time, TimeUnit.MINUTES);
    }

    public void deleteKey(String key){
        redisTemplate.delete(key);
    }

}
